package com.sky.web.servlet;

import java.util.List;
import java.io.IOException;
import java.sql.SQLException;

import com.sky.domain.Book;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sky.service.BookService;

public class QueryBookServlet extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      
	   BookService bookService =new BookService();
	  try {
		List<Book>	list = bookService.queryBookList();
		  request.setAttribute("booklist", list);
	        request.getRequestDispatcher("product/list.jsp").forward(request, response);
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		response.getWriter().write("查询图书列表失败，原因是："+e.getMessage());
	}
       
      
	
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

	
}
